//
// Created by 崔世强 on 2018/6/1.
// Copyright (c) 2018 Facebook. All rights reserved.
//

import Foundation
import UIKit

class ChatTabBarController: UITabBarController {
    var level: Int = 1
    //    let service = SessionService()
    var sessionList = [ChatSession]()
    var servicePlatformBarItem:UITabBarItem!
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if self.viewControllers?.count == 3 {
            //       loadData()
            
            //      NotificationCenter.default.addObserver(self, selector: #selector(onNewMsg), name: NSNotification.Name(rawValue: newMsg), object: nil)
        }else {
        }
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let v1 = SessionVC()
        v1.title = "聊天"
        
//        v1.tabBarItem = UITabBarItem (title: "聊天", image: UIImage(named: "tstChat_Default"), selectedImage: UIImage(named: "tstChat_Seclected")?.withRenderingMode(.alwaysOriginal))
        v1.tabBarItem = UITabBarItem (title: "聊天", image: UIImage(named: "tstChat_Default"), selectedImage: UIImage(named: "tstChat_Seclected"))
        let nav1: UINavigationController = UINavigationController(rootViewController: v1)
        
        
        let v4 = MTContactVC()
//        let v4 = ContactVC()
        v4.title = "通讯录"
        v4.tabBarItem = UITabBarItem.init(title: "通讯录", image: UIImage.init(named: "tstAddressBook_Default"), selectedImage: UIImage.init(named: "tstAddressBook_Secleted"))
        let nav4: UINavigationController = UINavigationController(rootViewController: v4)
        
        
        let meVC = UIStoryboard(name: "Me", bundle: Bundle.main).instantiateViewController(withIdentifier: "Me.Navi") as! UINavigationController
        let vc = meVC.topViewController
        vc?.title = "我"
        vc?.tabBarItem = UITabBarItem.init(title: "我", image: #imageLiteral(resourceName: "tabbar_me"), selectedImage: #imageLiteral(resourceName: "tabbar_meHL"))
        
        let tabArr = [nav1,nav4,meVC]
        self.viewControllers = tabArr
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        NotificationCenter.default.removeObserver(self)
    }
}
